# -*- coding: utf-8 -*-
from zhipuai import ZhipuAI
from glm.config import API_KEY

# 填写您自己的APIKey
client = ZhipuAI(api_key=API_KEY)


def chat_llm(query: str):
    """
    调用glm模型
    :param query: 查询内容
    :return: 回答内容
    """
    response = client.chat.completions.create(
        model="glm-4-flash",  # 填写需要调用的模型编码
        messages=[
            {"role": "user", "content": query}
        ],
    )
    return response.choices[0].message.content
